package com.demo.base.ega;

import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : YU.TAN
 * @date : 2021/8/26 15:54
 */
@Service
public class OrderSync implements SyncJob {

    @Autowired
    private SyncJobHandler syncJobHandler;

    private static final List<SyncEnum> nextTasks = new ArrayList<>();


    static {
        nextTasks.add(SyncEnum.ORDER_REPORT);
        nextTasks.add(SyncEnum.ORDER_VEHICLE_MATCH);
        nextTasks.add(SyncEnum.TRY_DRIVE_RECORD);

    }

    @Override
    public Object doSync(SyncParams syncParams) {
        System.out.println("这是销售订单旅程");
        nextTasks.forEach(syncEnum -> {
            syncParams.setSyncEnum(syncEnum);
            syncNext(syncParams);
        });
        return null;
    }

    @Override
    public SyncEnum jobType() {
        return SyncEnum.ORDER_DATA;
    }

    @SneakyThrows
    @Override
    public void syncNext(SyncParams syncParams) {
        syncJobHandler.doSync(syncParams);
    }
}
